//    Copyright (C) Kherty.  All rights reserved.
using System.Windows.Media;
using OpenLS.Core.Serialization;

namespace OpenLS.Drawing
{
    #if SILVERLIGHT
    static class BrushHelper
    {
        public static void Freeze (this Brush brush)
            {}
    }
    #endif
    public class SolidColorFillProperties : LineFillProperties
    {
        private ColorBase _color;

        public SolidColorFillProperties()
        {
            _color = new SRgbColor(Colors.White);
        }

        public SolidColorFillProperties(ColorBase color)
        {
            this._color = color;
        }

        public ColorBase Color
        {
            get { return _color; }
            //\\set { color = value; }
        }


        internal override Brush ToBrush(ColorScheme colorScheme)
        {
            if (Color == null)
                return null;
            SolidColorBrush result = new SolidColorBrush(Color.ResolveColor(colorScheme));
            result.Freeze();
            return result;
        }


        internal override void ReadXmlCore(ReadContext context)
        {
            using (var c = context.Read("solidFill"))
            {
                _color = ColorBase.ReadColor(c);
            }
        }

        internal override void WriteXmlCore(WriteContext context)
        {
            using (WriteContext c = context.Write("solidFill"))
            {
                c.WriteElement(Color);
            }
        }
    }
}